package entity.fields.properties;

import java.awt.Color;

import controllers.FieldController;
import dto.PropertyField;

public class Street extends PropertyField {

	private int[] rents = new int[6];
	private int buildings;
	private final static int BUILDINGS_MAX = 5;
	private int housePrice;
	private Color color;

	public Street(String name, Color color, int price, int rent, int rent1H, int rent2H, int rent3H, int rent4H, int rentHotel, int housePrice, FieldController fieldController) {
		super(fieldController, name, price);
		this.color = color;
		this.housePrice = housePrice;
		this.rents[0] = rent;
		this.rents[1] = rent1H;
		this.rents[2] = rent2H;
		this.rents[3] = rent3H;
		this.rents[4] = rent4H;
		this.rents[5] = rentHotel;
	}

	public Color getColor() {
		return color;
	}

	public int getBuildings() {
		return buildings;
	}

	public int getHousePrice() {
		return housePrice;
	}

	public void addBuilding() {
		if (buildings <= 4) {
			buildings++;
		}
	}

	public void setBuildings(int buildings) {
		this.buildings = buildings;
	}

	@Override
	public int getRent() {
		return rents[buildings];
	}
	
	@Override
	public String toString() {
		if (getOwner() == null)
			return "Pris: " + getPrice();
		else
			return "Leje: " + getRent();
	}

	@Override
	public String getDescription() {
		return "Lejer: " + rents[0] + ", " + rents[1] + ", " + rents[2] + ", " + rents[3] + ", " + rents[4] + ", " + rents[5];
	}
	
	@Override
	public void reset() {
		buildings = 0;
	}

	public boolean hasAllBuildings() {
		return getBuildings()==BUILDINGS_MAX;
	}

}
